
import 'package:todo_app/thirdpart/flutter_fms/flutter_fms.dart';
import 'package:todo_app/utils/call/states/ConnectingState.dart';
import 'package:todo_app/utils/call/states/TalkState.dart';

class TalkTransition extends ITransition {

  TalkTransition({ TalkState? talkState }) : super(toState: talkState);

  @override
  bool check() {
    if(toState == null || fromState == null) return false;
    if(fromState is ConnectingState) {
      final ConnectingState connectingState = fromState as ConnectingState;
      if(connectingState.context?.requestSuccess == false) return true;
      if(connectingState.context?.requestSuccess == true) {
        final TalkState talkState = toState as TalkState;
        if(connectingState.context?.room.room_id == talkState.context?.room.room_id) return true;
      }
    }
    return false;
  }

  @override
  String get name => "TalkTransition";

  @override
  bool? onCompleteCallBack() => null;
}